<?php

namespace App\Service;
use App\Common\Tools;
use App\Exception\BusinessException;
use App\Repository\ContactsRepo;
use App\Repository\UserRepo;

/**
 * 联系人相关业务类
 *
 * @author WangBin
 */
class ContactsService extends Singleton
{
    /**
     * 获取联系人列表
     *
     * @param array $params
     */
    public function getList(array $params)
    {
        if(empty($params['auto_user_id'])) {
            BusinessException::error(500, "用户 id 不能为空");
        }
        $result = ContactsRepo::getInstance()->getByUserId($params['auto_user_id']);
        return $this->toList($result, $this->getPage($params['page']), $this->getPageSize($params['page_size']));
    }
}